var data_info;

function alertInfo() {
	
	var myAlert = document.getElementById("alert_info");
	if (this.id == "user_height") {
		// document.getElementById("alert_number").value=jsondata.height;
		document.getElementById("alert_pedometerGoal_select").value = jsondata.height;
		document.getElementById("alert_info_title").innerHTML = "身高 cm";
		// document.getElementById("danwei").innerHTML="cm";
		data_info = "height";
		createSelectItem(jsondata.height, 10, 240);

	} else if (this.id == "user_weight") {
		// document.getElementById("alert_number").value=jsondata.weight;
		document.getElementById("alert_pedometerGoal_select").value = jsondata.weight;
		document.getElementById("alert_info_title").innerHTML = "体重 kg";
		// document.getElementById("danwei").innerHTML="kg";
		data_info = "weight";
		createSelectItem(jsondata.weight, 10, 200);

	}
	myAlert.style.display = "block";
	myAlert.style.position = "absolute";
	var mybg = document.createElement("div");
	mybg.setAttribute("id", "alert_bg");
	mybg.style.background = "#000";
	mybg.style.width = "100%";
	mybg.style.height = document.body.scrollHeight + "px";
	mybg.style.position = "absolute";
	mybg.style.overflow = "hidden";
	mybg.style.top = "0";
	mybg.style.left = "0";
	mybg.style.zIndex = "2500";
	mybg.style.opacity = "0.3";
	mybg.style.filter = "Alpha(opacity=30)";
	document.body.appendChild(mybg);
	document.body.style.overflow = "hidden";

	// document.getElementById("alert_number").focus();
	document.getElementById("alert_pedometerGoal_select").focus();

}

function outtime() {
	setTimeout(removeMybg, 500);
}

function removeMybg() {
	var mybg = document.getElementById("alert_bg");
	var myAlert = document.getElementById("alert_info");
	document.body.style.overflow = "visible";
	myAlert.style.display = "none";
	document.body.removeChild(mybg);
	// document.getElementById("alert_number").blur();
	document.getElementById("alert_pedometerGoal_select").blur();
}
function date_close() {
	var mybg = document.getElementById("alert_bg");
	var myAlert = document.getElementById("alert_DateWin");
	document.body.style.overflow = "visible";
	myAlert.style.display = "none";
	document.body.removeChild(mybg);
	// document.getElementById("alert_number_date").blur();
	document.getElementById("alert_pedometerGoal_select").blur();
}
var user_sex_value = 1;
function changeSex() {
	// var user_sex=document.getElementById("user_sex");
	if (user_sex_value == 2) {
		user_sex_value = 1;
		// user_sex.style.backgroundImage='url('+ctx+'/v2/img/setting_sex_man.png)';
	} else {
		user_sex_value = 2;
		// user_sex.style.backgroundImage='url('+ctx+'/v2/img/setting_sex_woman.png)';
	}
	ajaxEditData(user_sex_value);
}

function add_data(temp) {
//	if (data_info == "height") {
//		ajaxEditData("height");
//	} else if (data_info == "weight") {
//		ajaxEditData("weight");
//	}
//	removeMybg();
	ajaxEditData(temp);
}
function add_data_height() {
//	checkChange = 0;
//	alert('height');
	ajaxEditData('height');
}
function add_data_weight() {
//	checkChange = 0;
//	alert('weight');
	ajaxEditData('weight');
}
//function add_data_waist() {
////	checkChange = 0;
////	alert('weight');
//	ajaxEditData('waist');
//}

function add_data_weightGoal() {
//	checkChange = 0;
//	alert('weight');
	ajaxEditData('weightGoal');
}

function add_data_pedometerGoal() {
//	checkChange = 0;
//	alert('weight');
	ajaxEditData('pedometerGoal');
}

function add_data_birthday() {
//	checkChange = 0;
//	alert('weight');
	ajaxEditData("birthday");
}

// 日期格式化
Date.prototype.format = function(format) {
	/*
	 * format="yyyy-MM-dd hh:mm:ss";
	 */
	var o = {
		"M+" : this.getMonth() + 1,
		"d+" : this.getDate(),
		"h+" : this.getHours(),
		"m+" : this.getMinutes(),
		"s+" : this.getSeconds(),
		"q+" : Math.floor((this.getMonth() + 3) / 3),
		"S" : this.getMilliseconds()
	};
	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	}
	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;

};
// 更新数据
function ajaxEditData(info) {
	var memberId = document.getElementById("memberId").value;
	var memberId_p = document.getElementById("memberId_p").value;
	
	var xhr = createXmlHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var json = xhr.responseText;
				jsondata = eval("(" + json + ")");// 转换后的JSON对象
				initdata();
			} else {
				alert(err);
			}
		}
	};
	var url = ctx + "/wechat/ajax_manydevice_setting";
	 if (info == "height") {
		// var number = new Number(document.getElementById("alert_number").value).toFixed(1);
		// var number = new Number(document.getElementById("alert_pedometerGoal_select").value).toFixed(1);
		var number = document.getElementById("select_height_value").value;
//		if (number < 10 || number > 999) {
//			return;
//		}
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&height=" + number + "&&roundNumber=" + new Date(), true);
	} else if (info == "weight") {
		// var number = new
		// Number(document.getElementById("alert_number").value).toFixed(1);
		// var number = new
		// Number(document.getElementById("alert_pedometerGoal_select").value).toFixed(1);
		var number = document.getElementById("select_weight_value").value;
//		if (number < 10 || number > 999) {
//			return;
//		}
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&weight=" + number + "&&roundNumber=" + new Date(), true);
	} else if (info == "weightGoal") {
		
		var number = document.getElementById("select_weightGoal_value").value;
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&weightGoal=" + number + "&&roundNumber=" + new Date(), true);
		
	} else if (info == "pedometerGoal") {
		
		var number = document.getElementById("select_pedometerGoal_value").value;
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&pedometerGoal=" + number + "&&roundNumber=" + new Date(), true);
		
	}else if (info == 1) {
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&sex=" + 1 + "&&roundNumber=" + new Date(), true);
	} else if (info == 2) {
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId +"&&memberId_p="+memberId_p
				+ "&&sex=" + 2 + "&&roundNumber=" + new Date(), true);
	}else if(info=="birthday"){
		var birthday_input_iphone=document.getElementById("birthday_input_iphone");
		var val= new Date(Date.parse(birthday_input_iphone.value+"-01-01")).format("yyyy-MM-dd");
		
		xhr.open("post", url + "?setting=setting_edit&&memberId=" + memberId+"&&memberId_p="+memberId_p+"&&birthday="+val, true);
	}


	xhr.send();
}
//日期格式化
Date.prototype.format = function(format) {
    /*
     * format="yyyy-MM-dd hh:mm:ss";
     */
    var o = {
        "M+" : this.getMonth() + 1,
        "d+" : this.getDate(),
        "h+" : this.getHours(),
        "m+" : this.getMinutes(),
        "s+" : this.getSeconds(),
        "q+" : Math.floor((this.getMonth() + 3) / 3),
        "S" : this.getMilliseconds()
    };
    if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4- RegExp.$1.length));
        }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)){
            format = format.replace(RegExp.$1, RegExp.$1.length == 1? o[k]:("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
    
};

// 初始化数据
function initdata() {
	var icon = document.getElementById("icon");
	if (jsondata.headimgurl != null && jsondata.headimgurl != "") {
		var headImgUrl=jsondata.headimgurl;
		headImgUrl=headImgUrl.substring(0, (headImgUrl.length-1));
		headImgUrl+="64";
		icon.style.backgroundImage = "url(" + headImgUrl + ")";
	} else {
		icon.style.backgroundImage = "url('" + ctx + "/v2/img/user.png')";
	}

	var user_name = document.getElementById("user_name");
	var name_data = jsondata.name;
	user_name.innerHTML = name_data;
	if(name_data.length>10)
		user_name.style.width = "180px";
	
	var user_sex = document.getElementById("user_sex");
	if (jsondata.sex == 2) {
		user_sex_value = 2;
		user_sex.src = ctx + '/v2/img/setting_sex_woman2.png';
	} else {
		user_sex_value = 1;
		user_sex.src = ctx + '/v2/img/setting_sex_man2.png';
	}

	var birthday_input_iphone=document.getElementById("birthday_input_iphone");
	var user_birthday_text1=document.getElementById("user_birthday_text1");
//	var user_birthday_text2=document.getElementById("user_birthday_text2");
//	var birthday_year = document.getElementById("birthday_year");
//	var birthday_month = document.getElementById("birthday_month");
//	var birthday_day = document.getElementById("birthday_day");
	
	
	if(jsondata.birthday.time!=null&&jsondata.birthday.time!=""){
//		birthday_input_iphone.value=new Date(jsondata.birthday.time).format("yyyy-MM-dd");
		birthday_input_iphone.value=new Date(jsondata.birthday.time).format("yyyy");
		
		tvalue=birthday_input_iphone.value;
		user_birthday_text1.innerHTML=new Date(jsondata.birthday.time).format("yyyy");
//		user_birthday_text2.innerHTML=new Date(jsondata.birthday.time).format("MM")+"月"+new Date(jsondata.birthday.time).format("dd")+"日";
//		birthday_year.value=new Date(jsondata.birthday.time).format("yyyy");
//		birthday_month.value = new Date(jsondata.birthday.time).format("MM");
//		birthday_day.value = new Date(jsondata.birthday.time).format("dd");
	}else{
//		birthday_input_iphone.value="1985-01-01";
	}
	
	// var user_height_text = document.getElementById("user_height_text");
	// user_height_text.innerHTML=jsondata.height;
	// user_height_text.style.display="block";
	// var user_weight_text=document.getElementById("user_weight_text");
	// user_weight_text.innerHTML=jsondata.weight;
	// user_weight_text.style.display="block";

	var select_height_value = document.getElementById("select_height_value");
	var height_value = jsondata.height;
	if(height_value>=100&&height_value<=240){
		select_height_value.value = height_value.toFixed(0);
	}else{
		select_height_value.value = 240;
	}
	
//	var select_waist_value = document.getElementById("select_waist_value");
//	var waist_value = jsondata.waist;
//	if(waist_value>=30&&waist_value<=150){
//		select_waist_value.value = waist_value;
//	}else{
//		select_waist_value.value = 150;
//	}
	
	var select_weightGoal_value = document.getElementById("select_weightGoal_value");
	var weightGoal_value = jsondata.weightGoal;
	if(weightGoal_value>=30&&weightGoal_value<=150){
		select_weightGoal_value.value = weightGoal_value;
	}else{
		select_weightGoal_value.value = 150;
	}
	
	var select_pedometerGoal_value = document.getElementById("select_pedometerGoal_value");
	var pedometerGoal_value = jsondata.pedometerGoal;
	if(pedometerGoal_value>=1000&&pedometerGoal_value<=100000){
		select_pedometerGoal_value.value = pedometerGoal_value;
	}else{
		select_pedometerGoal_value.value = 5000;
	}
	
	var select_weight_value = document.getElementById("select_weight_value");
	var weight_value = jsondata.weight;
	if(weight_value<30){
		weight_value = select_weight_value.value = 30;
	}else if(weight_value>150){
		weight_value = select_weight_value.value = 150;
	}else{
		select_weight_value.value = weight_value.toFixed(0);
	}
	if(weight_value<100){
		select_weight_value.style.paddingLeft = "calc(50% - 14px)";
	}else{
		select_weight_value.style.paddingLeft = "calc(50% - 19px)";
	}
	
	var user_weight_text=document.getElementById("user_weight_text");
	user_weight_text.innerHTML= weight_value.toFixed(0);
	var user_height_text = document.getElementById("user_height_text");
	user_height_text.innerHTML= height_value;
//	var user_waist_text = document.getElementById("user_waist_text");
//	user_waist_text.innerHTML= waist_value;
	
	var user_weightGoal_text = document.getElementById("user_weightGoal_text");
	user_weightGoal_text.innerHTML= weightGoal_value;
	
	var user_pedometerGoal_text = document.getElementById("user_pedometerGoal_text");
	user_pedometerGoal_text.innerHTML= pedometerGoal_value;
	step = pedometerGoal_value;
	
	if(pedometerGoal_value >=100000){
		user_pedometerGoal_text.style.fontSize = "20px";
	}else{
		user_pedometerGoal_text.style.fontSize = "22px";
	}
	
	// 设备电量
//	var batteryPercent = document.getElementById("hidden_batteryPercent").value;
//	document.getElementById("batteryPercent_text").innerHTML = parseFloat(batteryPercent)
//			+ "%";

}

function ajaxInitData() {
	var memberId = document.getElementById("memberId").value;
	var openId=document.getElementById("openId").value;
	var enterpriseId=document.getElementById("enterpriseId").value;
	var userType=document.getElementById("userType").value;
	var xhr = createXmlHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var json = xhr.responseText;
				if (json == "900001") {
					to(json);
					return;
				}
				if (json.length > 0) {
					var jsonData = eval("(" + json + ")");// 转换后的JSON对象
					jsondata = jsonData;
					
					initdata();
					
					document.getElementById("sbody").style.display = "block";
				} else {
					// httpTimeOut();
				}
			}
		}
	};
	var url = ctx + "/wechat/ajax_manydevice_setting";
	xhr.open("post", url + "?memberId=" + memberId
			+ "&&setting=setting_load&&roundNumber=" + new Date()+"&&userType="+userType+"&&openId="+openId+"&&enterpriseId="+enterpriseId, true);
	xhr.send();
}
window.onload = function() {
	
	var param = GetRequest();
	document.getElementById("openId").value=param["openId"];
	document.getElementById("memberId").value=param["memberId"];
	wxcheckWXSignature();
//	parent.document.title = "个人设置";
//	
//	
//	window.addEventListener("pagehide", function(){
//	    parent.selectMenu(0);
//	    setTimeout(function(){},100); 
//	}, false);
//	window.addEventListener("pageshow", function(){
//	    parent.selectMenu(3);
//	    setTimeout(function(){},100); 
//	}, false);
//	
//	var name = navigator.platform;
//	if (name.substring(0, 6) == "iPhone" || name.substring(0, 4) == "iPod"
//			|| name.substring(0, 4) == "iPad") {
//		var ibody=document.getElementsByTagName("body")
//		ibody[0].addEventListener("touchstart", parent.clickHiddenSetting, false);
//	} else {
//		var ibody=document.getElementsByTagName("body")
//		ibody[0].addEventListener("click", parent.clickHiddenSetting, false);
//	}
//	
//	var pedometermemberId = parent.document.getElementById("pedometermemberId").value;
//	var weightmemberId = parent.document.getElementById("weightmemberId").value;
//	if(weightmemberId!=""){
//		document.getElementById("openId").value=parent.document.getElementById("weightopenId").value;
//		document.getElementById("memberId").value=weightmemberId;
//	}else{
//		document.getElementById("openId").value=parent.document.getElementById("pedometeropenId").value;
//		document.getElementById("memberId").value=pedometermemberId;
//	}
//	document.getElementById("memberId_p").value=pedometermemberId;
//	
	//document.getElementById("hidden_batteryPercent").value=parent.document.getElementById("batteryPercent").value;
	
//	initNavbar(3);
	
	createSelectForHightOrWeight();
	
	var name = navigator.platform;
	if (name.substring(0, 6) == "iPhone" || name.substring(0, 4) == "iPod"
			|| name.substring(0, 4) == "iPad") {
		init_iphone_onclick();
	} else {
		init_html_onclick();
	}
	
	
	ajaxInitData();

	// initdata();
//	load_pedometerGoal();
	
	
//	//获取浏览器内核 是否是奇葩- -
//	function getAndroidUA(){
//		var uaName = navigator.userAgent;
//		return uaName.substring(uaName.indexOf("; Android") - 1, uaName.indexOf("; Android"));
//	}
//	if(getAndroidUA() == "U"){
//		//不支持HTML5 input Date的浏览器
//		initData4AndroidUA();
//	}
	
};

function initData4AndroidUA(){
	var birthday_input_iphone=document.getElementById("birthday_input_iphone");
	
	birthday_input_iphone.addEventListener("click", alertWin2, false);
	
	
}

var tvalue;
var timer;
function input_onfocus() {
	timer=setInterval(function(){
		var birthday_input_iphone=document.getElementById("birthday_input_iphone");
		if(birthday_input_iphone.value!=tvalue){
			birthday_save();
		}
			
	}, 100);
//	document.getElementById("birthday_input_iphone").focus();
	// document.getElementById("birthday_input_iphone").click();
}
function input_blur() {
	clearInterval(timer);
}
var step;
var alertStep;
// 读取目标步数
function load_pedometerGoal() {
	var memberId = document.getElementById("memberId").value;
	var xhr = createXmlHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var json = xhr.responseText;
				if (json == "900001") {
//					X
					to(json);
					return;
				}
				if (json.length > 0) {
					var jsonData = eval("(" + json + ")");// 转换后的JSON对象
					step = jsonData.pedometerGoal;
					alertStep = step;
//					document.getElementById("pedomterGoal").innerHTML = step;

					 document.getElementById("user_pedometerGoal_text").innerHTML=step;
					 document.getElementById("alert_pedometerGoal_value").innerHTML = step;

//					show_text_ico();
					removeMybg2();
					document.getElementById("select_weight_value").blur();
					value_change();
				} else {
					// httpTimeOut();
				}
			}
		}
	};
	var url = ctx + "/wechat/ajax_member_edit";
	xhr.open("post", url + "?memberId=" + memberId
			+ "&&action_member=actionLoad&&roundNumber=" + new Date(), true);
	xhr.send();
}

// 添加目标步数
function add_pedometerGoal() {
	var memberId = document.getElementById("memberId").value;
	var memberId_p = document.getElementById("memberId_p").value;
	
	var pedometerGoal = document.getElementById("alert_pedometerGoal_value").innerHTML;
	if (pedometerGoal < 0) {
		alert("目标步数不能小于0");
		return;
	}
	var xhr = createXmlHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var json = xhr.responseText;
				if (json == "900001") {
					to(json);
					return;
				}
				load_pedometerGoal();
				// removeMybg2();
			} else {
				// alert(err);
			}
		}
	};
	var url = ctx + "/wechat/ajax_member_edit";
	xhr.open("post", url + "?memberId=" + memberId +"&&memberId_p="+memberId_p+ "&&stepGoal="
			+ pedometerGoal + "&&action_member=addGoal&&roundNumber="
			+ new Date(), true);
	xhr.send();
}

function alertWin() {
	// load_pedometerGoal();
	document.getElementById("alert_pedometerGoal_value").innerHTML = step;
	value_change();
	// console.log(alertStep+"-----"+step);

	if (step > 1000) {
		document.getElementById("alert_value_reduce").style.display = "block";
	} else {
		document.getElementById("alert_value_reduce").style.display = "none";
	}
	if(step>=144000){
		document.getElementById("alert_value_plus").style.display = "none";
	}else{
		document.getElementById("alert_value_plus").style.display = "block";
	}
	var myAlert = document.getElementById("alert_pedometerGoal");
	myAlert.style.display = "block";
	myAlert.style.position = "absolute";
	var mybg = document.createElement("div");
	mybg.setAttribute("id", "alert_bg");
	mybg.style.background = "#000";

	mybg.style.width = "100%";
	mybg.style.height = document.body.scrollHeight + "px";
	mybg.style.position = "absolute";
	mybg.style.overflow = "hidden";
	mybg.style.top = "0";
	mybg.style.left = "0";
	mybg.style.zIndex = "2500";
	mybg.style.opacity = "0.3";

	document.body.appendChild(mybg);
	document.body.style.overflow = "hidden";

}

function alertWin2() {
	birthday_input_iphone.blur();
	
	var myAlert = document.getElementById("alert_birthday");
	myAlert.style.display = "block";
	myAlert.style.position = "fixed";
	var mybg = document.createElement("div");
	mybg.setAttribute("id", "alert_bg");
	mybg.style.background = "#000";

	mybg.style.width = "100%";
	mybg.style.height = document.body.scrollHeight + "px";
	mybg.style.position = "fixed";
	mybg.style.overflow = "hidden";
	mybg.style.top = "0";
	mybg.style.left = "0";
	mybg.style.zIndex = "2500";
	mybg.style.opacity = "0.3";

	document.body.appendChild(mybg);
	document.body.style.overflow = "hidden";

}

// 目标数圆环显示
function show_text_ico() {

	// var step=document.getElementById("alert_pedometerGoal_value").innerHTML;
	var distance = alertStep * 0.4 / 1000;
//	var walkingTime = distance / 5;
	var walkingTime=alertStep/100/60;
	var wth = 0;
	var wtm = 0;
	if (walkingTime != 0) {
		var str = parseFloat(walkingTime).toFixed(2);
		var point = str.indexOf(".");
		wth = str.substring(0, point);
		var str1 = str.substring(point + 1, str.length);
		wtm = str1 * 0.6;
		wtm = parseFloat(wtm).toFixed(0);
	}

//	if (alertStep < 5999) {
//		document.getElementById("float_img").src = ctx
//				+ "/v2/img/setting_100.png";
//	} else if (alertStep < 9999) {
//		document.getElementById("float_img").src = ctx
//				+ "/v2/img/setting_6000.png";
//	} else {
//		document.getElementById("float_img").src = ctx
//				+ "/v2/img/setting_10000.png";
//	}

//	var tips_time_h_display = document.getElementById("tips_time_h_display");
//	var tips_walkingTime_h = document.getElementById("tips_walkingTime_h");
//	var tips_walkingTime_m = document.getElementById("tips_walkingTime_m");
//	var tips_time_m_display = document.getElementById("tips_time_m_display");
//	var hedden_tips_m = document.getElementById("hedden_tips_m");
//	var tips_div_top = document.getElementById("tips_div_top");
//	var pg_dian = document.getElementById("pg_dian");

	alert_pedometerGoal_walkingTime_h.innerHTML = wth + "小时";
	alert_pedometerGoal_walkingTime_m.innerHTML = wtm + "分钟";
//	tips_time_h_display.innerHTML = "小时";
//	tips_time_m_display.innerHTML = "分钟";
//	tips_walkingTime_h.innerHTML = wth;
//	tips_walkingTime_m.innerHTML = wtm;
//	tips_time_h_display.style.display = "block";
//	tips_time_m_display.style.display = "block";
//	hedden_tips_m.style.display = "block";
//	tips_div_top.ckassName = "tips_div tips_div_top1";
//	pg_dian.style.height = "100px";
//	pg_dian.style.paddingTop = "30px";
//	if (wth <= 0) {
		// alert_pedometerGoal_walkingTime_h.innerHTML="";
//		tips_walkingTime_h.innerHTML = wtm;
//		tips_time_h_display.innerHTML = "分钟";
//		hedden_tips_m.style.display = "none";
//	}
//	if (wtm <= 0) {
		// tips_div_top.ckassName = "tips_div tips_div_top1";
		// alert_pedometerGoal_walkingTime_m.innerHTML="";
//		hedden_tips_m.style.display = "none";
//	}
//	if (hedden_tips_m.style.display == "block") {
//		pg_dian.style.height = "110px";
//		pg_dian.style.paddingTop = "20px";
//	}
}
function value_change() {
	var step = document.getElementById("alert_pedometerGoal_value").innerHTML;
	// var step = alertStep;
	// var height = document.getElementById("user_height_text").innerHTML/100;
	// var weight = document.getElementById("user_weight_text").innerHTML;

	var height = document.getElementById("select_height_value").value / 100;
	var weight = document.getElementById("select_weight_value").value;
	// 获取目标热量消耗
	var calories_text = Math.round(getCalories(weight, step));
	// 目标距离
	var td_text = Math.round(getTD(height, step));

	var distance = step * 0.4 / 1000;
	var calories = step / 30;
	var walkingTime=step/100/60;
//	var walkingTime = distance / 5;
	var runningTime = distance / 10;
	if (distance != 0) {
		var str = parseFloat(distance).toFixed(1);
		var point = str.indexOf(".");
		var str1 = str.substring(point + 1, str.length);
		if (str1 == "0") {
			str = str.substring(0, point);
		}
		distance = str;
	}
	if (calories != 0) {
		var str = parseFloat(calories).toFixed(1);
		var point = str.indexOf(".");
		var str1 = str.substring(point + 1, str.length);
		if (str1 == "0") {
			str = str.substring(0, point);
		}
		calories = str;
	}
	var wth = 0;
	var wtm = 0;
	if (walkingTime != 0) {
		var str = parseFloat(walkingTime).toFixed(2);
		var point = str.indexOf(".");
		wth = str.substring(0, point);
		var str1 = str.substring(point + 1, str.length);
		wtm = str1 * 0.6;
		wtm = parseFloat(wtm).toFixed(0);
		// walkingTime=str;
	}

	// 图标切换
	if (step < 5999) {
		document.getElementById("alert_pedometerGoal_level_ico").src = ctx
				+ "/v2/img/foot_fail.png";
		// document.getElementById("float_img").src
		// =ctx+"/v2/img/setting_100.png";
	} else if (step < 9999) {
		document.getElementById("alert_pedometerGoal_level_ico").src = ctx
				+ "/v2/img/foot_pass.png";
		// document.getElementById("float_img").src
		// =ctx+"/v2/img/setting_6000.png";
	} else {
		document.getElementById("alert_pedometerGoal_level_ico").src = ctx
				+ "/v2/img/foot_great.png";
		// document.getElementById("float_img").src
		// =ctx+"/v2/img/setting_10000.png";
	}
	var alert_pedometerGoal_walkingTime_h = document
			.getElementById("alert_pedometerGoal_walkingTime_h");
	var alert_pedometerGoal_walkingTime_m = document
			.getElementById("alert_pedometerGoal_walkingTime_m");

	alert_pedometerGoal_walkingTime_h.innerHTML = wth + "小时";
	alert_pedometerGoal_walkingTime_m.innerHTML = wtm + "分钟";

	if (wth <= 0) {
		alert_pedometerGoal_walkingTime_h.innerHTML = "";

	}
	if (wtm <= 0) {
		alert_pedometerGoal_walkingTime_m.innerHTML = "";

	}

	document.getElementById("alert_pedometerGoal_TD").innerHTML = td_text + "米";
	document.getElementById("alert_pedometerGoal_Calories").innerHTML = calories_text
			+ "大卡";
	var textLength = document.getElementById("alert_pedometerGoal_text").innerHTML.length;
	if (textLength > 230) {
		document.getElementById("alert_pedometerGoal_text").className = "alert_pedometerGoal_text alert_pedometerGoal_text_long";
	} else {
		document.getElementById("alert_pedometerGoal_text").className = "alert_pedometerGoal_text";
	}
	
	var user_pedometerGoal_text = document.getElementById("user_pedometerGoal_text");
	if(step >=100000){
		user_pedometerGoal_text.style.fontSize = "20px";
	}else{
		user_pedometerGoal_text.style.fontSize = "22px";
	}
}

function pedometerGoal_plus() {
	var value = document.getElementById("alert_pedometerGoal_value").innerHTML;
	value = parseInt(value) + 500;
	if (value >= 144000) {
		// 隐藏+号
		document.getElementById("alert_value_plus").style.display = "none";
	}
	if (value > 1000) {
		// 显示-号
		document.getElementById("alert_value_reduce").style.display = "block";
	}
	if (value > 144000) {
		pedometerGoal_stop();
		return;
	}
	alertStep = value;
	document.getElementById("alert_pedometerGoal_value").innerHTML = value;
	value_change();
}
function pedometerGoal_reduce() {
	var value = document.getElementById("alert_pedometerGoal_value").innerHTML;
	value = parseInt(value) - 500;
	if (value == 1000) {
		// 隐藏-号
		document.getElementById("alert_value_reduce").style.display = "none";
	}
	if (value < 144000) {
		// 显示+号
		document.getElementById("alert_value_plus").style.display = "block";
	}
	if (value < 1000) {
		pedometerGoal_stop();
		return;
	}
	alertStep = value;
	document.getElementById("alert_pedometerGoal_value").innerHTML = value;
	value_change();
}
var timer;
function pedometerGoal_plus_loop() {
	clearTimeout(timer);
	var i = 0;
	timer = setInterval(function() {
		i++;
		if (i > 50) {
			pedometerGoal_plus();
		}
	}, 10);
}
function pedometerGoal_reduce_loop() {
	clearTimeout(timer);
	var i = 0;
	timer = setInterval(function() {
		i++;
		if (i > 50) {
			pedometerGoal_reduce();
		}
	}, 10);
}
function pedometerGoal_stop() {
	clearTimeout(timer);
}
// 弹出框移除背景
function removeMybg2() {
	var mybg = document.getElementById("alert_bg");
	var myAlert = document.getElementById("alert_pedometerGoal");
	document.body.style.overflow = "visible";
	myAlert.style.display = "none";

	if (mybg != null) {
		document.body.removeChild(mybg);
	}
	// load_pedometerGoal();
}

//弹出框移除背景
function removeMybg3() {
	var mybg = document.getElementById("alert_bg");
	var myAlert = document.getElementById("alert_birthday");
	document.body.style.overflow = "visible";
	myAlert.style.display = "none";

	if (mybg != null) {
		document.body.removeChild(mybg);
	}
	// load_pedometerGoal();
}

/**
 * 目标热量消耗=0.0004*体重*目标步数 获取目标热量消耗 千卡（未精确小数）
 */
function getCalories(weight, step) {
	return 0.0004 * weight * step;

}
/**
 * 目标距离=身高*0.4*目标步数。身高单位是米，结果单位也是米 获取目标距离 m（未精确小数）
 */
function getTD(height, step) {
	return height * 0.4 * step;
	;
}

function touchStart_alert_value_plus(event) {
	var i = 0;
	timer = setInterval(function() {
		i++;
		if (i > 50 || i == 1) {
			pedometerGoal_plus();
		}
	}, 10);
}
function touchEnd_alert_value_plus(event) {
	// pedometerGoal_plus();
	pedometerGoal_stop();
}
function touchStart_alert_value_reduce(event) {
	var i = 0;
	timer = setInterval(function() {
		i++;
		if (i > 50 || i == 1) {
			pedometerGoal_reduce();
		}
	}, 10);
}
function touchEnd_alert_value_reduce(event) {
	// pedometerGoal_reduce();
	pedometerGoal_stop();
}

function init_iphone_onclick() {
//	var hSave = document.getElementById("select_height_value");
//	hSave.addEventListener("foucs", showSelectBg, false);
//	
//	var wSave = document.getElementById("select_weight_value");
//	wSave.addEventListener("foucs", showSelectBg, false);
//	var clickCheck = document.getElementById("clickRegion");
//	clickCheck.addEventListener("click", removeFocus, false);

//	var hSave = document.getElementById("select_height_value");
//	hSave.addEventListener("change", iphone_add_data_height, false);
//	
//	var wSave = document.getElementById("select_weight_value");
//	wSave.addEventListener("change", iphone_add_data_weight, false);
	
	var hSave = document.getElementById("select_height_value");
	hSave.addEventListener("change", add_data_height, false);
	hSave.addEventListener("focus", showSelectBg, false);
	hSave.addEventListener("blur", removeSelectBg, false);
	
	var wSave = document.getElementById("select_weight_value");
	wSave.addEventListener("change", add_data_weight, false);
	wSave.addEventListener("focus", showSelectBg, false);
	wSave.addEventListener("blur", removeSelectBg, false);
	
//	var waSave = document.getElementById("select_waist_value");
//	waSave.addEventListener("change", add_data_waist, false);
//	waSave.addEventListener("focus", showSelectBg, false);
//	waSave.addEventListener("blur", removeSelectBg, false);
	
	
	var waSave = document.getElementById("select_weightGoal_value");
	waSave.addEventListener("change", add_data_weightGoal, false);
	waSave.addEventListener("focus", showSelectBg, false);
	waSave.addEventListener("blur", removeSelectBg, false);
	
	
	var birthSave=document.getElementById("birthday_input_iphone");
	birthSave.addEventListener("change", add_data_birthday, false);
	birthSave.addEventListener("focus", showSelectBg, false);
	birthSave.addEventListener("blur", removeSelectBg, false);
	
	
	var peSave = document.getElementById("user_pedometer");
	peSave.addEventListener("click", alertWin, false);
//	peSave.addEventListener("touchstart", alertWin, false);
	
//	var peSave = document.getElementById("select_pedometerGoal_value");
//	peSave.addEventListener("change", add_data_pedometerGoal, false);
//	peSave.addEventListener("focus", showSelectBg, false);
//	peSave.addEventListener("blur", removeSelectBg, false);
	
//	var date=document.getElementById("user_birthday");
//	date.addEventListener("touchstart", input_onfocus, false);
	
//	var sex=document.getElementById("birthday_input_iphone");
//	sex.addEventListener("blur", birthday_save3, false);
//	sex.addEventListener("change", birthday_save3, false);
//	sex.addEventListener("blur", removeSelectBg, false);
//	sex.addEventListener("focus", showSelectBg, false);
//	sex.addEventListener("input", birthday_clear, false);
	
	// var height=document.getElementById("user_height");
	// height.addEventListener("touchend", alertInfo, false);
	// var weight=document.getElementById("user_weight");
	// weight.addEventListener("touchend", alertInfo, false);
//	var mSave = document.getElementById("alert_info_save");
//	mSave.addEventListener("touchstart", add_data, false);
//	var mClose = document.getElementById("alert_info_close");
//	mClose.addEventListener("touchstart", outtime, false);
//	var pedomterGoal = document.getElementById("pg_dian");
//	pedomterGoal.addEventListener("touchstart", alertWin, false);

	// 弹出框
//	var mClose = document.getElementById("alert_pedometerGoal_close");
//	mClose.addEventListener("touchend", removeMybg2, false);
//	var mSave = document.getElementById("alert_pedometerGoal_save");
//	mSave.addEventListener("touchend", add_pedometerGoal, false);
	var mClose = document.getElementById("alert_pedometerGoal_close");
	mClose.addEventListener("click", removeMybg2, false);
	var mSave = document.getElementById("alert_pedometerGoal_save");
	mSave.addEventListener("touchend", add_pedometerGoal, false);
	var mPlus =document.getElementById("alert_value_plus");
	 mPlus.addEventListener("touchstart",touchStart_alert_value_plus,false);
	 mPlus.addEventListener("touchend",touchEnd_alert_value_plus,false);
	 mPlus.addEventListener("touchmove",touchEnd_alert_value_plus,false);
	 var mReduce =document.getElementById("alert_value_reduce");
	 mReduce.addEventListener("touchstart",touchStart_alert_value_reduce,false);
	 mReduce.addEventListener("touchend",touchEnd_alert_value_reduce,false);
	 mPlus.addEventListener("touchmove",touchEnd_alert_value_reduce,false);
	
	var dClose = document.getElementById("alert_birthday_close");
	dClose.addEventListener("click", removeMybg3, false);
	var dSave = document.getElementById("alert_birthday_save");
	dSave.addEventListener("touchend", birthday_save2, false);
}

function init_html_onclick() {
	var hSave = document.getElementById("select_height_value");
	hSave.addEventListener("change", add_data_height, false);
	
	var wSave = document.getElementById("select_weight_value");
	wSave.addEventListener("change", add_data_weight, false);
	
//	var waSave = document.getElementById("select_waist_value");
//	waSave.addEventListener("change", add_data_waist, false);
	
	var waSave = document.getElementById("select_weightGoal_value");
	waSave.addEventListener("change", add_data_weightGoal, false);
	
	var peSave = document.getElementById("user_pedometer");
	peSave.addEventListener("click", alertWin, false);
	
//	var date=document.getElementById("user_birthday");
//	date.addEventListener("click", input_onfocus, false);
	
	var sex=document.getElementById("birthday_input_iphone");
	sex.addEventListener("change", add_data_birthday, false);
//	sex.addEventListener("click", input_onfocus, false);
//	sex.addEventListener("blur", input_blur, false);
	
	
//	sex.addEventListener("change", birthday_save, false);
	// var height=document.getElementById("user_height");
	// height.addEventListener("click", alertInfo, false);
	// var weight=document.getElementById("user_weight");
	// weight.addEventListener("click", alertInfo, false);
//	var mSave = document.getElementById("alert_info_save");
//	mSave.addEventListener("click", add_data, false);
//	var mClose = document.getElementById("alert_info_close");
//	mClose.addEventListener("click", removeMybg, false);

//	var pedomterGoal = document.getElementById("pg_dian");
//	pedomterGoal.addEventListener("click", alertWin, false);

	// 弹出框
	 var mPlus =document.getElementById("alert_value_plus");
	 mPlus.addEventListener("touchstart",touchStart_alert_value_plus,false);
	 mPlus.addEventListener("touchend",touchEnd_alert_value_plus,false);
	 mPlus.addEventListener("touchmove",touchEnd_alert_value_plus,false);
	 var mReduce =document.getElementById("alert_value_reduce");
	 mReduce.addEventListener("touchstart",touchStart_alert_value_reduce,false);
	 mReduce.addEventListener("touchend",touchEnd_alert_value_reduce,false);
	 mReduce.addEventListener("touchmove",touchEnd_alert_value_reduce,false);
//	var mPlus = document.getElementById("alert_value_plus");
//	mPlus.addEventListener("click", pedometerGoal_plus, false);
//	mPlus.addEventListener("mousedown", pedometerGoal_plus_loop, false);
//	mPlus.addEventListener("mouseup", pedometerGoal_stop, false);
//	var mReduce = document.getElementById("alert_value_reduce");
//	mReduce.addEventListener("click", pedometerGoal_reduce, false);
//	mReduce.addEventListener("mousedown", pedometerGoal_reduce_loop, false);
//	mReduce.addEventListener("mouseup", pedometerGoal_stop, false);
	var mSave = document.getElementById("alert_pedometerGoal_save");
	mSave.addEventListener("click", add_pedometerGoal, false);
	var mClose = document.getElementById("alert_pedometerGoal_close");
	mClose.addEventListener("click", removeMybg2, false);
	
	var dSave = document.getElementById("alert_birthday_save");
	dSave.addEventListener("click", birthday_save2, false);
	var dClose = document.getElementById("alert_birthday_close");
	dClose.addEventListener("click", removeMybg3, false);
}

function move(){
	alert(1);
}

//function input_onfocus(){
//	document.getElementById("birthday_input_iphone").focus();
////	document.getElementById("birthday_input_iphone").select();
////	document.getElementById("birthday_input_iphone").input();
//}
/**
 * 个人设置弹出框下拉选项框
 * 
 * @param initN
 * @param beginN
 * @param endN
 */
function createSelectItem(initN, beginN, endN) {
	var alertSelect = document.getElementById("alert_pedometerGoal_select");
	var html;
	// 身高
	for (var int = beginN; int <= endN; int++) {
		// var option = document.createAttribute("option");
		// option.value = int;
		// alertSelect.appendChild(option);
		html += '<option value="' + int + '">' + int + '</option>';

	}
	;
	alertSelect.innerHTML = html;
	alertSelect.value = initN;

};
/**
 * 创建身高/体重滚动选项列
 */
function createSelectForHightOrWeight() {
	var selectHeight = document.getElementById("select_height_value");
	var selectWeight = document.getElementById("select_weight_value");
//	var selectWaist = document.getElementById("select_waist_value");
	var selectWeightGoal = document.getElementById("select_weightGoal_value");
	var selectPedometerGoal = document.getElementById("select_pedometerGoal_value");
	var birthday_input_iphone = document.getElementById("birthday_input_iphone");

	//身高范围
	var heightBeginN = 100;
	var heightEndN = 240;
	//体重范围
	var weightBeginN = 30;
	var weightEndN = 150;
	
//	//腰围范围
//	var waistBeginN = 30;
//	var waistEndN = 150;
	
	//体重目标范围
	var weightGoalBeginN = 30;
	var weightGoalEndN = 150;
	
	//运动目标
	var pedometerGoalBeginN = 1000;
	var pedometerGoalEndN = 100000;
	
	//出生年
	var birthBeginN = 1930;
	var birthEndN = new Date().format("yyyy");

	var htmlStr="";
//	var htmlStrW;

	for (var i = heightBeginN; i <= heightEndN; i++) {
		htmlStr += '<option value="' + i + '">' + i
				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cm'
				+ '</option>';
	}
	selectHeight.innerHTML = htmlStr;

	htmlStr = "";
	for (var j = weightBeginN; j <= weightEndN; j++) {
		htmlStr += '<option value="' + j + '">' + j
				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kg'
				+ '</option>';
	}
	selectWeight.innerHTML = htmlStr;
	
//	htmlStr = "";
//	for (var j = waistBeginN; j <= waistEndN; j++) {
//		htmlStr += '<option value="' + j + '">' + j
//				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cm'
//				+ '</option>';
//	}
//	selectWaist.innerHTML = htmlStr;
	
	htmlStr = "";
	for (var j = weightGoalBeginN; j <= weightGoalEndN; j++) {
		htmlStr += '<option value="' + j + '">' + j
				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kg'
				+ '</option>';
	}
	selectWeightGoal.innerHTML = htmlStr;
	
	htmlStr = "";
	for (var j = pedometerGoalBeginN; j <= pedometerGoalEndN; j=j+500) {
		htmlStr += '<option value="' + j + '">' + j
				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;步'
				+ '</option>';
	}
	selectPedometerGoal.innerHTML = htmlStr;
	
	htmlStr = "";
	for (var j = birthBeginN; j <= birthEndN; j++) {
		htmlStr += '<option value="' + j + '">' + j
				+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年'
				+ '</option>';
	}
	birthday_input_iphone.innerHTML = htmlStr;
}
//滚轮背景
function showSelectBg(){
	
	var name = navigator.platform;
	if (name.substring(0, 6) == "iPhone" || name.substring(0, 4) == "iPod"
			|| name.substring(0, 4) == "iPad") {
		parent.document.getElementById("navbar").style.position = "static";
	}
	
	var mybg = parent.document.createElement("div");
	mybg.setAttribute("id", "alert_bg");
	mybg.style.background = "#000";

	mybg.style.width = "100%";
	mybg.style.height = parent.document.body.scrollHeight + "px";
	mybg.style.position = "absolute";
	mybg.style.overflow = "hidden";
	mybg.style.top = "0";
	mybg.style.left = "0";
	mybg.style.zIndex = "2500";
	mybg.style.opacity = "0.3";

	parent.document.body.appendChild(mybg);
	parent.document.body.style.overflow = "hidden";
}
//移除滚轮背景
function removeSelectBg(){
	parent.document.getElementById("navbar").style.position = "fixed";
	var mybg = parent.document.getElementById("alert_bg");
	parent.document.body.style.overflow = "visible";
	parent.document.body.removeChild(mybg);
}
//function testA(){
//	checkChange = 1;
////	alert(checkChange+"test");
////	iphone_add_data_weight();
//}
//var checkChange = 0;
//function iphone_add_data_weight(){
//	if(checkChange > 0){
//		document.getElementById("select_weight_value").selectIndex = -1;
//	}else{
//		add_data_weight();
//	}
//	
//}
//function iphone_add_data_height(){
//	if(checkChange > 0){
//		document.getElementById("select_height_value").selectIndex = -1;
//	}else{
//		add_data_height();
//	}
//	
//}
//移除滚轮焦点 隐藏滚轮
//function removeFocus(){
//	document.getElementById("select_weight_value").selectIndex = -1;
//	document.getElementById("select_height_value").selectIndex = -1;
//}

function birthday_save(){
	var birthday_input_iphone=document.getElementById("birthday_input_iphone");
	var user_birthday_text1=document.getElementById("user_birthday_text1");
	var user_birthday_text2=document.getElementById("user_birthday_text2");
	
	//过滤时间  范围为1894-01-01到今天
	var startTime = new Date("1894-01-01");
	var endTime = new Date();
	var birthdayTime =  new Date(Date.parse(birthday_input_iphone.value));
	
	if(startTime <= birthdayTime && birthdayTime <= endTime){
		tvalue=birthday_input_iphone.value;
		ajaxEditData("birthday");
	}else{
		alert("无效的时间");
		birthday_input_iphone.value = tvalue;
		clearInterval(timer);
	}
}

function birthday_save3(){
	var birthday_input_iphone=document.getElementById("birthday_input_iphone");
	
	//过滤时间  范围为1894-01-01到今天
//	var startTime = new Date(Date.parse("1894-01-01"));
	var startTime = new Date("1894-01-01");
	var endTime = new Date();
	var birthdayTime =  new Date(Date.parse(birthday_input_iphone.value));
	
	if(startTime <= birthdayTime && birthdayTime <=endTime){
		tvalue=birthday_input_iphone.value;
		ajaxEditData("birthday");
		removeSelectBg();
	}else{
		alert("无效的时间");
		birthday_input_iphone.value = tvalue;
	}
	
}
function birthday_save2(){
	
	var birthday_year = document.getElementById("birthday_year");
	var birthday_month = document.getElementById("birthday_month");
	var birthday_day = document.getElementById("birthday_day");
	
	var regYear = /^[1-2]\d{3}$/;
	if(!regYear.test(birthday_year.value)){
		alert("日期格式输入错误！");
		return;
	}
	var reg = /^\d{2}$/;
	if(!reg.test(birthday_month.value)){
		alert("日期格式输入错误！");
		return;
	}
	
	if(!reg.test(birthday_day.value)){
		alert("日期格式输入错误！");
		return;
	}
	
	if(birthday_month.value >12){
		alert("月份输入错误！");
		return;
	}
	
	//判断月份的天数是否输入正确
	if(isLeapYear(birthday_year.value)){//是闰年
		if(birthday_month.value == 2){
			if(birthday_day.value >29){
				alert("2月份的日期输入错误！");
				return;
			}
		}
		
		
	}else{//不是闰年
		if(birthday_month.value == 2){
			if(birthday_day.value >28){
				alert("2月份的日期输入错误！");
				return;
			}
		}
	}
	
	//月份的天数是否输入正确
	if(birthday_month.value == 1 ||birthday_month.value == 3 ||birthday_month.value == 5 ||birthday_month.value == 7 ||birthday_month.value == 8 ||birthday_month.value == 10 ||birthday_month.value == 12){
		if(birthday_day.value >31){
			alert("月份的日期输入错误！");
			return;
		}
	}else{
		if(birthday_day.value >30){
			alert("月份的日期输入错误！");
			return;
		}
	}
	
	
	var birthday = birthday_year.value+"-"+birthday_month.value+"-"+birthday_day.value;
	var birthday_input_iphone = document.getElementById("birthday_input_iphone");
	birthday_input_iphone.value=new Date(birthday).format("yyyy-MM-dd");
	
	
	var startTime = new Date("1894-01-01");
	var endTime = new Date();
	var birthdayTime =  new Date(birthday);
	
	if(startTime <= birthdayTime && birthdayTime <=endTime){
		tvalue=birthday_input_iphone.value;
		ajaxEditData("birthday");
		removeMybg3();
	}else{
		alert("无效的时间");
		birthday_input_iphone.value = tvalue;
	}
	
//	ajaxEditData("birthday");
	
}

//判断是否为闰年
function isLeapYear(year){
	if(year % 4 == 0 && year % 100 !=0){
		return true;
	}else{
		if(year % 400 == 0){
			return true;
		}else{
			return false;
		}
	}
}
